﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using SysCommon.Tools;

using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.SystemUI;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.Geodatabase;

namespace CVSS.Client.CIQS.UI
{
    public class VehicleStatByAreaFormMDT
    {
        VehicleStatByAreaForm frm = new VehicleStatByAreaForm();
        string m_CurrentOrgName = "";
        public SysCommon.Entity.Business.Stat.View.View_Statcarbyarea_Ety[] etys_pass;

        #region 界面初始化ShowForm
        /// <summary>
        /// 界面初始化
        /// </summary>
        /// <returns></returns>
        public bool ShowForm()
        {
            try
            {
                frm.Load += new EventHandler(frm_Load);
                frm.ShowDialog();
                return true;
            }
            catch (Exception ex)
            {
                SysCommon.Global.mainLog.Error("调用CVSS.Client.CIQS.UI.VehicleStatByAreaFormMDT出错", ex);
                return false;
            }
        }
        #endregion

        void frm_Load(object sender, EventArgs e)
        {
            SysCommon.MsgBox.ProecssingMessageBox.StartProecssing(this.frm, "正在加载窗体，请稍候...");
            System.Windows.Forms.Application.DoEvents();
            frm.btn_ExportToExcel.Click += new EventHandler(btn_ExportToExcel_Click);
            frm.btn_Print.Click += new EventHandler(btn_Print_Click);
            frm.btn_Start.Click += new EventHandler(btn_Start_Click);

            //By tw 2010-5-27
            //
            //工具栏
            //
            frm.mapTools.tsb_Cancel.Image_A = AppResources.Res.Resources.GetImage("pointer_base.bmp");
            frm.mapTools.tsb_Cancel.Image_B = AppResources.Res.Resources.GetImage("pointer_base.bmp");
            frm.mapTools.tsb_Cancel.Image_C = AppResources.Res.Resources.GetImage("pointer_base.bmp");

            frm.mapTools.tsb_Find.Image_A = AppResources.Res.Resources.GetImage("Find_base.BMP");
            frm.mapTools.tsb_Find.Image_B = AppResources.Res.Resources.GetImage("Find_base.BMP");
            frm.mapTools.tsb_Find.Image_C = AppResources.Res.Resources.GetImage("Find_base.BMP");

            frm.mapTools.tsb_FullExtent.Image_A = AppResources.Res.Resources.GetImage("full_extent_base.bmp");
            frm.mapTools.tsb_FullExtent.Image_B = AppResources.Res.Resources.GetImage("full_extent_base.bmp");
            frm.mapTools.tsb_FullExtent.Image_C = AppResources.Res.Resources.GetImage("full_extent_base.bmp");

            frm.mapTools.tsb_Identity.Image_A = AppResources.Res.Resources.GetImage("information_base.bmp");
            frm.mapTools.tsb_Identity.Image_B = AppResources.Res.Resources.GetImage("information_base.bmp");
            frm.mapTools.tsb_Identity.Image_C = AppResources.Res.Resources.GetImage("information_base.bmp");

            frm.mapTools.tsb_Measure.Image_A = AppResources.Res.Resources.GetImage("measure_base.bmp");
            frm.mapTools.tsb_Measure.Image_B = AppResources.Res.Resources.GetImage("measure_base.bmp");
            frm.mapTools.tsb_Measure.Image_C = AppResources.Res.Resources.GetImage("measure_base.bmp");

            frm.mapTools.tsb_NextView.Image_A = AppResources.Res.Resources.GetImage("ReDoDraw_base.bmp");
            frm.mapTools.tsb_NextView.Image_B = AppResources.Res.Resources.GetImage("ReDoDraw_base.bmp");
            frm.mapTools.tsb_NextView.Image_C = AppResources.Res.Resources.GetImage("ReDoDraw_base.bmp");

            frm.mapTools.tsb_Pan.Image_A = AppResources.Res.Resources.GetImage("pan_base.bmp");
            frm.mapTools.tsb_Pan.Image_B = AppResources.Res.Resources.GetImage("pan_base.bmp");
            frm.mapTools.tsb_Pan.Image_C = AppResources.Res.Resources.GetImage("pan_base.bmp");

            frm.mapTools.tsb_PreView.Image_A = AppResources.Res.Resources.GetImage("UnDoDraw_base.bmp");
            frm.mapTools.tsb_PreView.Image_B = AppResources.Res.Resources.GetImage("UnDoDraw_base.bmp");
            frm.mapTools.tsb_PreView.Image_C = AppResources.Res.Resources.GetImage("UnDoDraw_base.bmp");

            frm.mapTools.tsb_ZoomIn.Image_A = AppResources.Res.Resources.GetImage("zoom_in__base.bmp");
            frm.mapTools.tsb_ZoomIn.Image_B = AppResources.Res.Resources.GetImage("zoom_in__base.bmp");
            frm.mapTools.tsb_ZoomIn.Image_C = AppResources.Res.Resources.GetImage("zoom_in__base.bmp");

            frm.mapTools.tsb_ZoomOut.Image_A = AppResources.Res.Resources.GetImage("zoom_out_base.bmp");
            frm.mapTools.tsb_ZoomOut.Image_B = AppResources.Res.Resources.GetImage("zoom_out_base.bmp");
            frm.mapTools.tsb_ZoomOut.Image_C = AppResources.Res.Resources.GetImage("zoom_out_base.bmp");

            frm.mapTools.init(frm.axMapControl1);

            InitMap();

            //frm.btn_ExportToExcel.Enabled = false;
            //frm.btn_Print.Enabled = false;
            frm.dvp_DataView.OnDataChangedHandlerEvent += new SysCommon.UI.DataGridViewForPageCtrl.OnDataChangedHandler(dvp_DataView_OnDataChangedHandlerEvent);
            InitDataGridView();
            InitCombolBox();
            SysCommon.MsgBox.ProecssingMessageBox.EndProecssing();
        }

        #region 导出Excel
        /// <summary>
        /// 导出Excel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void btn_ExportToExcel_Click(object sender, EventArgs e)
        {
            try
            {
                //frm.btn_ExportToExcel.Enabled = false;
                SysCommon.Entity.Business.Stat.View.View_Statcarbyarea_Ety[] etys =
                    (SysCommon.Entity.Business.Stat.View.View_Statcarbyarea_Ety[])frm.dvp_DataView.dg_DataView.DataSource;
                if (etys == null)
                {
                    SysCommon.MsgBox.SysMessageBox.ShowInfoMessageBox(frm, "对不起，没有要导出的数据", false);
                    return;
                }
                if (etys.Length <= 0)
                {
                    SysCommon.MsgBox.SysMessageBox.ShowInfoMessageBox(frm, "对不起，没有要导出的数据", false);
                    return;
                }
                DateTime datetime = System.DateTime.Now;
                string path = Application.StartupPath + @"\Resource\ReportsTemplate\广东省车辆信息统计报表（辖区管理）.xls";

                Data.ExcelData.ExportVehicleInfoByArea(
                    path, etys, datetime);
            }
            catch (Exception ex)
            {
                SysCommon.Global.mainLog.Error("调用btn_ExportToExcel_Click出错", ex);
            }
            frm.btn_ExportToExcel.Enabled = true;
        }
        #endregion

        #region 打印
        /// <summary>
        /// 打印
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void btn_Print_Click(object sender, EventArgs e)
        {
            try
            {
                //frm.btn_ExportToExcel.Enabled = false;
                SysCommon.Entity.Business.Stat.View.View_Statcarbyarea_Ety[] etys =
                    (SysCommon.Entity.Business.Stat.View.View_Statcarbyarea_Ety[])frm.dvp_DataView.dg_DataView.DataSource;
                if (etys == null || etys.Length <= 0)
                {
                    SysCommon.MsgBox.SysMessageBox.ShowInfoMessageBox(frm, "对不起，没有要打印的数据", false);
                    return;
                }
                DateTime datetime = System.DateTime.Now;
                string path = Application.StartupPath + @"\Resource\ReportsTemplate\广东省车辆信息统计报表（辖区管理）.xls";

                Data.ExcelData.PrintVehicleInfoByArea(
                    path, etys, datetime);
            }
            catch (Exception ex)
            {
                SysCommon.Global.mainLog.Error("调用btn_ExportToExcel_Click出错", ex);
            }
            frm.btn_ExportToExcel.Enabled = true;
        }
        #endregion

        #region 开始统计
        /// <summary>
        /// 开始统计
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void btn_Start_Click(object sender, EventArgs e)
        {
            //StatInfo();
            //StatInfo2();//备份压缩
            try
            {
                SysCommon.MsgBox.ProecssingMessageBox.StartProecssing(this.frm, "正在加载数据，请稍候...");
                System.Windows.Forms.Application.DoEvents();
                StatInfoWithCompressForPage();//压缩且分页
                SysCommon.Entity.Business.Stat.View.View_Statcarbyarea_Ety[] m_Etys = (SysCommon.Entity.Business.Stat.View.View_Statcarbyarea_Ety[])frm.dvp_DataView.dg_DataView.DataSource;
                SysCommon.MsgBox.ProecssingMessageBox.EndProecssing();
                if (m_Etys == null || m_Etys.Length == 0)
                {
                    SysCommon.MsgBox.SysMessageBox.ShowInfoMessageBox(frm, "对不起，没有找到符合条件的结果", false);
                }
                else
                {
                    CVSS.Client.CIQS.Business.UpdateMapAttributes updateValue = 
                        new CVSS.Client.CIQS.Business.UpdateMapAttributes(m_Etys);

                    DrawBarGraph();
                }
            }
            catch (Exception ex)
            {
                SysCommon.Global.mainLog.Error("调用btn_Query_Click(object sender, EventArgs e)出错", ex);
            }
          
        }
        #endregion

        #region 其他基本信息初始化
        #region 初始化InitDataGridView
        /// <summary>
        /// 初始化DataGridView
        /// </summary>
        void InitDataGridView()
        {
            try
            {
                SysCommon.Entity.Business.Stat.View.View_Statcarbyarea_Ety[] etys =
                    new SysCommon.Entity.Business.Stat.View.View_Statcarbyarea_Ety[0];
                if (etys == null) return;
                string[] cn_col = new string[] { "辖区名称", "车辆类型", "车辆用途", "车辆数量" };
                string[] en_col = new string[] { "AREANAME", "CARTYPENAME", "CARUSENESS", "CARNUMBER" };

                SysCommon.Tools.ShowEntityForDataGridView.SetDefaultDataGrigStyle(frm.dvp_DataView.dg_DataView);
                SysCommon.Tools.ShowEntityForDataGridView.EntityToView(cn_col, en_col, etys, frm.dvp_DataView.dg_DataView);
                frm.dvp_DataView.dg_DataView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
            }
            catch (Exception ex)
            {
                SysCommon.Global.mainLog.Error("调用CVSS.Client.CIQS.UI.InitDataGridView出错", ex);
            }
        }
        #endregion

        #region InitCombolBox
        void InitCombolBox()
        {
            try
            {
                // 初始化辖区
                //InitArea();          
                InitArea2();

                //初始化车辆类型
                GetSystemSettings("VehicleType", frm.cmb_CarType);

                //初始化车辆用途
                InitCarUsess(frm.cmb_CarUsessType);
            }
            catch (Exception ex)
            {
                SysCommon.Global.mainLog.Error("调用CVSS.Client.CIQS.UI.InitDataGridView出错", ex);
            }
        }
        #endregion

        #region 初始化车辆用途信息
        /// <summary>
        /// 初始化车辆用途信息
        /// </summary>
        /// <param name="m_ComboBox"></param>
        void InitCarUsess(System.Windows.Forms.ComboBox m_ComboBox)
        {
            try
            {
                SysCommon.Entity.Vehicle.Car_Ety[] etys = null;
                m_ComboBox.Items.Clear();
                m_ComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
                SysCommon.Business.CVSS.WS.BaseData.WS_BaseData_BizCtrlImpl ws = new SysCommon.Business.CVSS.WS.BaseData.WS_BaseData_BizCtrlImpl();
                byte[] zipBuffer= ws.GetAllCarInfo2();
                etys = (SysCommon.Entity.Vehicle.Car_Ety[])CompressionHelper.DeCompressEntity(zipBuffer);
                m_ComboBox.Items.Add("全部");
                foreach (SysCommon.Entity.Vehicle.Car_Ety ety in etys)
                {
                    if (ety.CARUSENESS == null) continue;
                    if (m_ComboBox.Items.Contains(ety.CARUSENESS)) continue;

                    m_ComboBox.Items.Add(ety.CARUSENESS);
                }
                m_ComboBox.Text = "全部";
            }
            catch (Exception ex)
            {
                SysCommon.Global.mainLog.Error("调用InitCarUsess出错", ex);
            }
        }
        #endregion 


        #region 初始化车辆类型

        void GetSystemSettings(string name, System.Windows.Forms.ComboBox m_ComboBox)
        {
            try
            {
                m_ComboBox.Items.Clear();
                m_ComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;

                SysCommon.Business.CVSS.WS.BaseData.WS_BaseData_BizCtrlImpl m_ws = new SysCommon.Business.CVSS.WS.BaseData.WS_BaseData_BizCtrlImpl();
                SysCommon.Entity.CVSS.WS.BaseData.SysSetting_Ety[] etys = m_ws.SearchSysSettingInfo1(name);
                m_ComboBox.Items.Add("全部");
                foreach (SysCommon.Entity.CVSS.WS.BaseData.SysSetting_Ety ety in etys)
                {
                    if (m_ComboBox.Items.Contains(ety.DISPLAYVALUE)) continue;
                    m_ComboBox.Items.Add(ety.DISPLAYVALUE);
                }
                //m_ComboBox.Text = "全部";
                m_ComboBox.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                SysCommon.Global.mainLog.Error("调用CVSS.Client.CIQS.UI.GetSystemSettings出错", ex);
            }
        }
        #endregion

        #region 初始化辖区
        void InitArea()
        {
            try
            {
                //初始化辖区
                SysCommon.Entity.CVSS.WS.BaseData.View_Organization_Ety org = CIQS.CIQSGlobal.GetCurrentOrganization();
                string strAreaCode = org.AREACODE;
                m_CurrentOrgName = org.AREANAME;

                if (strAreaCode.EndsWith("0000"))
                {
                    strAreaCode = "44";
                }
                else
                {
                    strAreaCode = strAreaCode.Substring(0, 4);
                }
                SysCommon.Business.CVSS.WS.BaseData.WS_BaseData_BizCtrlImpl ws = new SysCommon.Business.CVSS.WS.BaseData.WS_BaseData_BizCtrlImpl();

                SysCommon.Entity.CVSS.WS.BaseData.AreaCode_Ety[] areaCode = ws.GetAllAreaInfo();

                frm.cmb_CarMember.Items.Clear();
                frm.cmb_CarMember.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
                frm.cmb_CarMember.Items.Add("全部");
                foreach (SysCommon.Entity.CVSS.WS.BaseData.AreaCode_Ety code in areaCode)
                {
                    if (code.CODE.Contains(strAreaCode))
                    {
                        frm.cmb_CarMember.Items.Add(code.NAME);
                    }
                }
                frm.cmb_CarMember.Text = "全部";
            }
            catch (Exception ex)
            {
                SysCommon.Global.mainLog.Error("初始化辖区列表出错！", ex);
            }
        }
        #endregion

        #region 初始化辖区(webservice压缩处理)
       /// <summary>
        /// 初始化辖区(webservice压缩处理)
       /// </summary>
        void InitArea2()
        {
            try
            {
                //初始化辖区
                SysCommon.Entity.CVSS.WS.BaseData.View_Organization_Ety org = CIQS.CIQSGlobal.GetCurrentOrganization();
                string strAreaCode = org.AREACODE;
                m_CurrentOrgName = org.AREANAME;

                if (strAreaCode.EndsWith("0000"))
                {
                    strAreaCode = "44";
                }
                else
                {
                    strAreaCode = strAreaCode.Substring(0, 4);
                }
                SysCommon.Business.CVSS.WS.BaseData.WS_BaseData_BizCtrlImpl ws = new SysCommon.Business.CVSS.WS.BaseData.WS_BaseData_BizCtrlImpl();
               SysCommon.Entity.Business.AreaCode_Ety[] areaCode = null;
                byte[] zipBuffer = ws.GetAllAreaInfo2();
                areaCode = (SysCommon.Entity.Business.AreaCode_Ety[])CompressionHelper.DeCompressEntity(zipBuffer);

                frm.cmb_CarMember.Items.Clear();
                frm.cmb_CarMember.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
                frm.cmb_CarMember.Items.Add("全部");
                foreach (SysCommon.Entity.Business.AreaCode_Ety code in areaCode)
                {
                    if (code.CODE.Contains(strAreaCode))
                    {
                        frm.cmb_CarMember.Items.Add(code.NAME);
                    }
                }
                frm.cmb_CarMember.Text = "全部";
            }
            catch (Exception ex)
            {
                SysCommon.Global.mainLog.Error("初始化辖区列表出错！", ex);
            }
        }
        #endregion
        #endregion

        #region 统计函数
        void StatInfo()
        {
            try
            {
                SysCommon.Business.CVSS.WS.Stat.WS_Stat_BizCtrlImpl ws =
                    new SysCommon.Business.CVSS.WS.Stat.WS_Stat_BizCtrlImpl();
                SysCommon.Entity.CVSS.WS.Stat.AreaStaUCondition_Ety query =
                    new SysCommon.Entity.CVSS.WS.Stat.AreaStaUCondition_Ety();

                query.AREANAME = frm.cmb_CarMember.Text.Trim();
                query.CARTYPE = frm.cmb_CarType.Text.Trim();
                query.CARUSENESS = frm.cmb_CarUsessType.Text.Trim();
                if (query.AREANAME == "全部")
                {
                    query.AREANAME = m_CurrentOrgName;
                    if (query.AREANAME == "广东省")
                        query.AREANAME = "";
                }
                if (query.CARTYPE == "全部") query.CARTYPE = "";
                if (query.CARUSENESS == "全部") query.CARUSENESS = "";
                SysCommon.Entity.CVSS.WS.Stat.View_Statcarbyarea_Ety[] etys = ws.StatCarInfoByArea(
                    query);

                if (etys == null)
                {
                    InitDataGridView();
                    SysCommon.MsgBox.SysMessageBox.ShowInfoMessageBox(frm, "对不起，没有符合条件的统计结果！", false);                    
                }
                else
                {
                    frm.dvp_DataView.dg_DataView.DataSource = etys;
                    if (etys.Length == 0)
                        SysCommon.MsgBox.SysMessageBox.ShowInfoMessageBox(frm, "对不起，没有符合条件的查询结果！", false);
                }

            }
            catch (Exception ex)
            {
                SysCommon.Global.mainLog.Error("调用StatInfo()出错", ex);
            }
        }
        #endregion

        #region 统计函数(webservice压缩处理)
        /// <summary>
        /// 统计函数(webservice压缩处理)
        /// </summary>
        void StatInfo2()
        {
            try
            {
                SysCommon.Business.CVSS.WS.Stat.WS_Stat_BizCtrlImpl ws = new SysCommon.Business.CVSS.WS.Stat.WS_Stat_BizCtrlImpl();
                SysCommon.Entity.CVSS.WS.Stat.AreaStaUCondition_Ety query = new SysCommon.Entity.CVSS.WS.Stat.AreaStaUCondition_Ety();
                SysCommon.Entity.Business.Stat.View.View_Statcarbyarea_Ety[] etys = null;
                query.AREANAME = frm.cmb_CarMember.Text.Trim();
                query.CARTYPE = frm.cmb_CarType.Text.Trim();
                query.CARUSENESS = frm.cmb_CarUsessType.Text.Trim();
                if (query.AREANAME == "全部")
                {
                    query.AREANAME = m_CurrentOrgName;
                    if (query.AREANAME == "广东省")
                        query.AREANAME = "";
                }
                if (query.CARTYPE == "全部") query.CARTYPE = "";
                if (query.CARUSENESS == "全部") query.CARUSENESS = "";
                byte[] zipBuffer = ws.StatCarInfoByArea2(query);
                etys = (SysCommon.Entity.Business.Stat.View.View_Statcarbyarea_Ety[])CompressionHelper.DeCompressEntity(zipBuffer);
                if (etys == null)
                {
                    InitDataGridView();
                    SysCommon.MsgBox.SysMessageBox.ShowInfoMessageBox(frm, "对不起，没有符合条件的统计结果！", false);
                }
                else
                {
                    frm.dvp_DataView.dg_DataView.DataSource = etys;
                    if (etys.Length == 0)
                        SysCommon.MsgBox.SysMessageBox.ShowInfoMessageBox(frm, "对不起，没有符合条件的查询结果！", false);
                    else
                    {
                        foreach (SysCommon.Entity.Business.Stat.View.View_Statcarbyarea_Ety ety in etys)
                        {
                            //ety.AREANAME;
                        }
                    }
                }

                //By tw 2010-5-27
                
            }
            catch (Exception ex)
            {
                SysCommon.Global.mainLog.Error("调用StatInfo2()出错",ex);
            }
        }
        #endregion

        #region 统计函数压缩分页
        /// <summary>
        /// 统计函数压缩分页
        /// </summary>
        void StatInfoWithCompressForPage()
        {
            try
            {
                int pageIndex = 1;
                int pageSize = 30;
                SysCommon.Business.CVSS.WS.Stat.WS_Stat_BizCtrlImpl ws = new SysCommon.Business.CVSS.WS.Stat.WS_Stat_BizCtrlImpl();
                SysCommon.Entity.CVSS.WS.Stat.AreaStaUCondition_Ety query = new SysCommon.Entity.CVSS.WS.Stat.AreaStaUCondition_Ety();
                //SysCommon.Entity.Business.Stat.View.View_Statcarbyarea_Ety[] etys = null;
                query.AREANAME = frm.cmb_CarMember.Text.Trim();
                query.CARTYPENAME = frm.cmb_CarType.Text.Trim();
                query.CARUSENESS = frm.cmb_CarUsessType.Text.Trim();
                if (query.AREANAME == "全部")
                {
                    query.AREANAME = m_CurrentOrgName;
                    if (query.AREANAME == "广东省")
                        query.AREANAME = "";
                }
                if (query.CARTYPENAME == "全部") query.CARTYPENAME = "";
                if (query.CARUSENESS == "全部") query.CARUSENESS = "";
                byte[] zipBuffer = ws.StatCarInfoByAreaWithCompressForPage(query,pageIndex,pageSize);
                 object obj =null;
                 if(zipBuffer!=null)
                 {
                     obj = SysCommon.Tools.CompressionHelper.DeCompressEntity(zipBuffer);
                     InitDataGridView();
                 }
                
                SysCommon.Entity.Business.CompressResult_Ety<SysCommon.Entity.Business.Stat.View.View_Statcarbyarea_Ety> result = obj
                    as SysCommon.Entity.Business.CompressResult_Ety<SysCommon.Entity.Business.Stat.View.View_Statcarbyarea_Ety>;

                string[] cn_col = new string[] { "辖区名称", "车辆类型", "车辆用途", "车辆数量" };
                string[] en_col = new string[] { "AREANAME", "CARTYPENAME", "CARUSENESS", "CARNUMBER" };
                if (result != null)
                    {
                        frm.dvp_DataView.Init(result.PageIndex, result.PageCount, result.PageSize, result.Objects, cn_col, en_col);

                    }
              
                else
                {
                    SysCommon.Entity.Business.Stat.View.View_Statcarbyarea_Ety[] etys =
                        new SysCommon.Entity.Business.Stat.View.View_Statcarbyarea_Ety[0];
                    frm.dvp_DataView.Init(0, 0, 0, etys,cn_col ,en_col );
                }
            }
            catch (Exception ex)
            {
                SysCommon.Global.mainLog.Error("调用StatInfoWithCompressForPage()出错", ex);
            }
        }

        #region  dvp_DataView_OnDataChangedHandlerEvent
        /// <summary>
        /// 数据改变时的处理函数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">当前页面数据参数</param>
        /// <returns>新数据</returns>
        object dvp_DataView_OnDataChangedHandlerEvent(object sender, SysCommon.UI.DataGridViewForPageCtrl.OnDataChangedHandlerEventArgs e)
        {
            int pageIndex = e.PageIndex;
            int countPerPage = e.PageSize;
            int pageSize = e.PageSize;
            SysCommon.MsgBox.ProecssingMessageBox.StartProecssing(this.frm, "正在加载数据，请稍候...");
            System.Windows.Forms.Application.DoEvents();
            SysCommon.Business.CVSS.WS.Stat.WS_Stat_BizCtrlImpl ws = new SysCommon.Business.CVSS.WS.Stat.WS_Stat_BizCtrlImpl();
            SysCommon.Entity.CVSS.WS.Stat.AreaStaUCondition_Ety query = new SysCommon.Entity.CVSS.WS.Stat.AreaStaUCondition_Ety();
            //SysCommon.Entity.Business.Stat.View.View_Statcarbyarea_Ety[] etys = null;
            query.AREANAME = frm.cmb_CarMember.Text.Trim();
            query.CARTYPE = frm.cmb_CarType.Text.Trim();
            query.CARUSENESS = frm.cmb_CarUsessType.Text.Trim();
            if (query.AREANAME == "全部")
            {
                query.AREANAME = m_CurrentOrgName;
                if (query.AREANAME == "广东省")
                    query.AREANAME = "";
            }
            if (query.CARTYPE == "全部") query.CARTYPE = "";
            if (query.CARUSENESS == "全部") query.CARUSENESS = "";
            byte[] zipBuffer = ws.StatCarInfoByAreaWithCompressForPage(query, pageIndex, pageSize);

            object obj = null;
            if (zipBuffer != null)
            {
                obj = SysCommon.Tools.CompressionHelper.DeCompressEntity(zipBuffer);
                InitDataGridView();
            }
            SysCommon.Entity.Business.CompressResult_Ety<SysCommon.Entity.Business.Stat.View.View_Statcarbyarea_Ety> result = obj
                as SysCommon.Entity.Business.CompressResult_Ety<SysCommon.Entity.Business.Stat.View.View_Statcarbyarea_Ety>;


            if (result != null)
            {
                SysCommon.MsgBox.ProecssingMessageBox.EndProecssing();
                return result.Objects;
            }
            return null;

        }
        #endregion

        #endregion

        //By tw 2010-5-27
        #region 柱状图渲染

        private void DrawBarGraph()
        {
            IGeoFeatureLayer layer;
            try
            {
                IChartRenderer pChartRenderer = new ChartRendererClass() as IChartRenderer;

                IRendererFields pRendererField = (IRendererFields)pChartRenderer;
                pRendererField.AddField("Hazard_Count", "危险品车");
                pRendererField.AddField("Coach_Count", "客运班车");
                pRendererField.AddField("Tour_Count", "旅游包车");
                pRendererField.AddField("Truck_Count", "重型货车和汽车列车");
                pRendererField.AddField("Material_Count", "散装物料车");
                pRendererField.AddField("Instructor_Count", "教练车");
                pRendererField.AddField("School_Count", "校车");

                IBarChartSymbol pBarChartSymbol = (IBarChartSymbol)new BarChartSymbolClass();
                pBarChartSymbol.Width = 12;

                IChartSymbol pChartSymbol = (IChartSymbol)pBarChartSymbol;
                pChartSymbol.MaxValue = 6;

                IMarkerSymbol pMarkerSymbol = (IMarkerSymbol)pBarChartSymbol;
                pMarkerSymbol.Size = 25;

                ISymbolArray pSymbolArray = (ISymbolArray)pBarChartSymbol;

                IFillSymbol pFillSymbol;

                pFillSymbol = (IFillSymbol)new SimpleFillSymbolClass(); //危险品车
                pFillSymbol.Color = GetRGBColor(213, 212, 252);
                pSymbolArray.AddSymbol((ISymbol)pFillSymbol);

                pFillSymbol = (IFillSymbol)new SimpleFillSymbolClass(); //客运班车
                pFillSymbol.Color = GetRGBColor(47, 208, 51);
                pSymbolArray.AddSymbol((ISymbol)pFillSymbol);

                pFillSymbol = (IFillSymbol)new SimpleFillSymbolClass(); //旅游包车
                pFillSymbol.Color = GetRGBColor(189, 57, 34);
                pSymbolArray.AddSymbol((ISymbol)pFillSymbol);

                pFillSymbol = (IFillSymbol)new SimpleFillSymbolClass(); //重型货车和汽车列车
                pFillSymbol.Color = GetRGBColor(187, 138, 36);
                pSymbolArray.AddSymbol((ISymbol)pFillSymbol);

                pFillSymbol = (IFillSymbol)new SimpleFillSymbolClass(); //散装物料车
                pFillSymbol.Color = GetRGBColor(172, 187, 36);
                pSymbolArray.AddSymbol((ISymbol)pFillSymbol);

                pFillSymbol = (IFillSymbol)new SimpleFillSymbolClass(); //教练车
                pFillSymbol.Color = GetRGBColor(38, 185, 155);
                pSymbolArray.AddSymbol((ISymbol)pFillSymbol);

                pFillSymbol = (IFillSymbol)new SimpleFillSymbolClass(); //校车
                pFillSymbol.Color = GetRGBColor(51, 95, 128);
                pSymbolArray.AddSymbol((ISymbol)pFillSymbol);

                pFillSymbol = (IFillSymbol)new SimpleFillSymbolClass();
                pFillSymbol.Color = GetRGBColor(239, 228, 190);

                pChartRenderer.ChartSymbol = (IChartSymbol)pBarChartSymbol;

                pChartRenderer.BaseSymbol = (ISymbol)pFillSymbol;
                pChartRenderer.Label = "车辆区域统计";
                pChartRenderer.UseOverposter = false;

                layer = (IGeoFeatureLayer)frm.axMapControl1.get_Layer(0);
                layer.Renderer = (IFeatureRenderer)pChartRenderer;

                frm.axMapControl1.ActiveView.Refresh();

                //System.Runtime.InteropServices.Marshal.ReleaseComObject(pChartRenderer);
            }
            catch (Exception err)
            {
                Console.WriteLine(err.Message);
            }					
        }


        //工具函数--取色
        private IRgbColor GetRGBColor(int pRed, int pGreen, int pBlue)
        {
            IRgbColor pRGB;
            pRGB = new RgbColorClass();
            pRGB.Red = pRed;
            pRGB.Green = pGreen;
            pRGB.Blue = pBlue;
            pRGB.UseWindowsDithering = true;

            return pRGB;
        }

        #endregion

        #region 地图初始化
        private void InitMap()
        {
            try
            {
                string strPath = @"E:\Map_Ey\zone.mxd";
                frm.axMapControl1.LoadMxFile(strPath);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #endregion
    }
}
